<template>
  <div>
    <select v-model.number="num">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
    </select>
    <button @click="clickIncrement">增加</button>
    <button @click="clickDecrement">减少</button>
    <button @click="clickIncrementIfOdd">奇数增加</button>
    <button @click="clickIncrementAsync">异步增加(延迟1S)</button>
  </div>
</template>

<script>
export default {
  name: 'CountUpdate',
  props: {
    increment: Function,
    decrement: Function,
    incrementIfOdd: Function,
    incrementAsync: Function,
  },
  data () {
    return {
      num: 1
    }
  },
  methods: {
    clickIncrement () {
      this.increment(this.num)
    },
    clickDecrement () {
      this.decrement(this.num)
    },
    clickIncrementIfOdd () {
      this.incrementIfOdd(this.num)
    },
    clickIncrementAsync () {
      this.incrementAsync(this.num)
    },
  }
}
</script>

<style scoped>

</style>
